<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../iquery/jquery-3.6.1.min.js"></script>
</head>
<body>
    <!-- 设置表格序号为偶数行的文本颜色 -->
    <table id="tab">
        <tbody>
            <tr>
                <td>第一行</td><td>第一行</td>
            </tr>
            <tr>
                <td>第二行</td><td>第二行</td>
            </tr>
            <tr>
                <td>第三行</td><td>第三行</td>
            </tr>
            <tr>
                <td>第四行</td><td>第四行</td>
            </tr>
            <tr>
                <td>第五行</td><td>第五行</td>
            </tr>
        </tbody>
    </table>
    <script type="text/javascript">


    $(document).ready(function(){
 
    $("tr:odd").css("background-color","red");
  
    $("tr:even").css("background-color","blue");
  
    });
    //console.log($('li:odd')); //获取下标奇数位
    //console.log($('li:even')); //获取下标偶数位
    // https://blog.csdn.net/qq_45991812/article/details/125404049
    </script>
</body>
</html>